package com.ruoyi.system.api;

import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysFile;
import com.ruoyi.system.api.factory.RemoteUploadFallbackFactory;
import com.ruoyi.system.api.interceptor.RemoteFileInterceptor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@FeignClient(contextId = "remoteUploadService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteUploadFallbackFactory.class, configuration = RemoteFileInterceptor.class)
public interface RemoteUploadService {
    /**
     * 上传文件
     *
     * @return 结果
     */
    @PostMapping(value = "/file/upload/{appId}/{ts}/{sign}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<String> upload(@RequestPart(value = "file") MultipartFile file);

    @PostMapping(value = "/file/upload4Url/{appId}/{ts}/{sign}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<SysFile> upload4Url(@RequestPart(value = "file") MultipartFile file);

    @GetMapping("/file/deleteFile/{appId}/{ts}/{sign}")
    R<Boolean> deleteFile(@RequestParam("fileIds") String[] fileIds);
}
